home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / ibm / fasrc1p2.arc / AS.H < prev    next >
C/C++ Source or Header  |  1990-07-15  |  7KB  |  137 lines

  1. /*
  2.  *      machine independent definitions and global variables
  3.  */
  4.  
  5. #define YES     1
  6. #define NO      0
  7. #define ERR     (-1)
  8.  
  9. #define MAXBUF  512     /* size of buffers */
  10. #ifndef FILENAME_MAX
  11.    #define FILENAME_MAX MAXBUF     /* longest file or path name allowed */
  12. #endif
  13. #define MAXOP   10      /* longest mnemonic */
  14. #define MAXLAB  16
  15. #define E_LIMIT 32
  16. #define P_LIMIT 64
  17.  
  18. /*      Character Constants     */
  19. #define NEWLINE '\n'
  20. #define TAB     '\t'
  21. #define BLANK   ' '
  22. #define EOS     '\0'
  23.  
  24. /*      Opcode Classes          */
  25. #define INH     0       /* Inherent                     */
  26. #define GEN     1       /* General Addressing           */
  27. #define IMM     2       /* Immediate only               */
  28. #define REL     3       /* Short Relative               */
  29. #define P2REL   4       /* Long Relative                */
  30. #define P1REL   5       /* Long Relative (LBRA and LBSR)*/
  31. #define NOIMM   6       /* General except for Immediate */
  32. #define P2GEN   7       /* Page 2 General               */
  33. #define P3GEN   8       /* Page 3 General               */
  34. #define RTOR    9       /* Register To Register         */
  35. #define INDEXED 10      /* Indexed only                 */
  36. #define RLIST   11      /* Register List                */
  37. #define P2NOIMM 12      /* Page 2 No Immediate          */
  38. #define P2INH   13      /* Page 2 Inherent              */
  39. #define P3INH   14      /* Page 3 Inherent              */
  40. #define GRP2    15      /* Group 2 (Read/Modify/Write)  */
  41. #define LONGIMM 16      /* Immediate mode takes 2 bytes */
  42. #define BTB     17      /* Bit test and branch          */
  43. #define SETCLR  18      /* Bit set or clear             */
  44. #define CPD     19      /* compare d               6811 */
  45. #define XLIMM   20      /* LONGIMM for X           6811 */
  46. #define XNOIMM  21      /* NOIMM for X             6811 */
  47. #define YLIMM   22      /* LONGIMM for Y           6811 */
  48. #define YNOIMM  23      /* NOIMM for Y             6811 */
  49. #define FAKE    24      /* convenience mnemonics   6804 */
  50. #define APOST   25      /* A accum after opcode    6804 */
  51. #define BPM     26      /* branch reg plus/minus   6804 */
  52. #define CLRX    27      /* mvi x,0                 6804 */
  53. #define CLRY    28      /* mvi y,0                 6804 */
  54. #define LDX     29      /* mvi x,expr              6804 */
  55. #define LDY     30      /* mvi y,expr              6804 */
  56. #define MVI     31      /* mvi                     6804 */
  57. #define EXT     32      /* extended                6804 */
  58. #define BIT     33      /* bit manipulation        6301 */
  59. #define SYS     34      /* syscalls (really swi)        */
  60. #define PSEUDO  35      /* Pseudo ops                   */
  61.  
  62. /* global variables */
  63. int     Line_num =0;            /* current cumulative line number       */
  64. int     Cf_line_num =0;         /* current line number in current file  */
  65. int     Err_count =0;           /* total number of errors       */
  66. int     Warn_count = 0;         /* total number of warnings     */
  67. char    Line[MAXBUF] = {0};     /* input line buffer            */
  68. char    Label[MAXLAB] = {0};    /* label on current line        */
  69. char    Op[MAXOP] = {0};        /* opcode mnemonic on current line      */
  70. char    Operand[MAXBUF] = {0};  /* remainder of line after Op           */
  71. char    *Optr =0;               /* pointer into current Operand field   */
  72. int     Result =0;              /* result of expression evaluation      */
  73. int     Term_err =0;            /* error flag for get_term()            */
  74. int     Force_word =0;          /* Result should be a word when set     */
  75. int     Force_byte =0;          /* Result should be a byte when set     */
  76. int     Pc =0;                  /* Program Counter              */
  77. int     Old_pc =0;              /* Program Counter at beginning */
  78. int     End = NO;               /* flag for END directive       */
  79. int     Entry_pt = 0;           /* program's entry point        */
  80. int     Entry_set = NO;         /* entry point specified flag   */
  81.  
  82. int     Last_sym =0;            /* result of last lookup        */
  83.  
  84. int     Pass =0;                /* Current pass #               */
  85. int     N_files =0;             /* Number of files to assemble  */
  86. FILE    *Fd =0;                 /* Current input file structure */
  87. int     Cfn =0;                 /* Current file number 1...n    */
  88. int     Ffn =0;                 /* forward ref file #           */
  89. int     F_ref =0;               /* next line with forward ref   */
  90. char    **Argv =0;              /* pointer to file names        */
  91.  
  92. int     E_total =0;             /* total # bytes for one line   */
  93. int     E_bytes[E_LIMIT] = {0}; /* Emitted held bytes           */
  94. int     E_pc =0;                /* Pc at beginning of collection*/
  95.  
  96. int     Lflag = 0;              /* listing flag 0=nolist, 1=list*/
  97.  
  98. int     P_force = 0;            /* force listing line to include Old_pc */
  99. int     P_total =0;             /* current number of bytes collected    */
  100. int     P_bytes[P_LIMIT] = {0}; /* Bytes collected for listing  */
  101.  
  102. int     Cpflag = 0;             /* print cumulative cycles flag
  103.                       bit 0:  count just turned off
  104.                       bit 1:  Lflag on before current line */
  105. int     Cflag = 0;              /* cycle count flag */
  106. int     Cycles = 0;             /* # of cycles per instruction  */
  107. long    Ctotal = 0;             /* # of cycles seen so far */
  108. int     Sflag = 0;              /* symbol table flag, 0=no symbol */
  109. int     N_page = 0;             /* new page flag */
  110. int     Page_num = 2;           /* page number */
  111. int     CREflag = 0;            /* cross reference table flag */
  112.  
  113. struct link { /* linked list to hold line numbers */
  114.        int L_num; /* line number */
  115.        struct link *next; /* pointer to next node */
  116. };
  117.  
  118. struct nlist { /* basic symbol table entry */
  119.         char    *name;
  120.         int     def;
  121.         struct nlist *Lnext ; /* left node of the tree leaf */
  122.         struct nlist *Rnext; /* right node of the tree leaf */ 
  123.         struct link *L_list; /* pointer to linked list of line numbers */
  124. };
  125.  
  126. struct oper {   /* an entry in the mnemonic table */
  127.         char    *mnemonic;      /* its name */
  128.         char    class;          /* its class */
  129.         int     opcode;         /* its base opcode */
  130.         char    cycles;         /* its base # of cycles */
  131. };
  132.  
  133. struct  nlist *root;            /* root node of the tree */
  134.   
  135. FILE    *Objfil =0;             /* object file's file descriptor*/
  136. char    Obj_name[FILENAME_MAX];
  137.